package com.zy.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.rest.pojo.ItemCatResult;
import com.zy.rest.service.ItemCatService;
@Controller
@RequestMapping("/itemcat")
public class ItemCatController {
	@Autowired
	private ItemCatService itemService;
	
	@RequestMapping("/all")
	@ResponseBody
	public MappingJacksonValue queryAll(String callback) throws Exception {
		// 查询分类列表
		ItemCatResult result = itemService.queryAllCategory();
		// 包装成jsonp
		MappingJacksonValue jacksonValue = new MappingJacksonValue(result);
		// 设置JSONP函数名称的名称。
		jacksonValue.setJsonpFunction(callback);
		return jacksonValue;
	}
}
